package ups.glre.news.web;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


public class StartupServlet extends HttpServlet {

	private static final long serialVersionUID = 1L;
	
//	@EJB
//    private NewsJmsService newsJmsService;
	
//	@EJB
//	private NewsService newsService;
	
//	@EJB
//	private NewsServiceBean newsServiceBean;

    @Override
    public void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {

    	response.setContentType("text/html");
        PrintWriter out = response.getWriter();

        out.println("<html>");
        out.println("<head>");
        out.println("<title>Hola</title>");
        out.println("</head>");
        out.println("<body bgcolor=\"white\">");

        out.println("<h1> HelloWorldEJB Says: </h1>");
        
//        UserService userService = newsServiceBean.getUserService();
//        userService.createUser("Yakhya","Dabo","yakhya.dabo","12345");
//		userService.createUser("Julien","Martin","julien.martin","12345");
//		userService.createUser("Ludovic","Dungar","ludovic.dungar","12345");
//		userService.createUser("Adrien","Lassere","adrien.lassere","12345");
    	
        if (request.getParameter("testJMS") != null) {
//        	newsJmsService.sendMessage("news", "title1", "author1", "content1", "date1");
//        } else if (request.getParameter("testCreateNewsJMS") != null) {
//        	newsService.createNews("Auteur2", "Titre2", "Content2");
//        } else if (request.getParameter("testReadNewsJMS") != null) {
//        	List<News> allNews = newsService.getAllNews();
//        	System.out.println("allNews=" + allNews);
//        	out.println("<h1> " + "allnews=" + allNews + " </h1>");
        }
        
        out.println("</body>");
        out.println("</html>");
    }
}
